package com.yami.shop.api.controller;

import com.yami.shop.dao.DistanceMapper;
import com.yami.shop.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
@RestController
@RequestMapping("/p/dist")
@Api(tags = "距离接口")
@AllArgsConstructor
public class DistanceController {

    @Autowired
    private DistanceMapper distanceMapper;

    @GetMapping("/editDistance")
    @ApiOperation(value = "经纬度接口", notes = "重新储存用户经纬度")
    public ResponseEntity<String> addAddr(Double lng, Double lat) {
        String userId = SecurityUtils.getUser().getUserId();

        distanceMapper.editLatitudeAndLongitude(userId,lng,lat);
        return ResponseEntity.ok("更新坐标成功");
    }

}
